var platform = null;

"undefined" != typeof wx && (platform = "wx"), "undefined" != typeof my && (platform = "my");

var modules = [ {
    name: "helper",
    file: "./utils/helper.js"
}, {
    name: "const",
    file: "./core/const.js"
}, {
    name: "bus",
    file: "./core/bus.js"
},{
    name: "getConfig",
    file: "./core/config.js"
}, {
    name: "page",
    file: "./core/page.js"
}, {
    name: "request",
    file: "./core/request.js"
}, {
    name: "core",
    file: "./core/core.js"
}, {
    name: "api",
    file: "./core/api.js"
}, {
    name: "getUser",
    file: "./core/getUser.js"
}, {
    name: "setUser",
    file: "./core/setUser.js"
}, {
    name: "login",
    file: "./core/login.js"
}, {
    name: "trigger",
    file: "./core/trigger.js"
}, {
    name: "uploader",
    file: "./utils/uploader.js"
}, {
    name: "orderPay",
    file: "./core/order-pay.js"
} ],args = {
    _version: "2.8.9",
    platform: platform,
    query: null,
    onLaunch: function() {
        this.getStoreData()
    },
    onShow: function(e) {
        e.scene && (this.onShowData = e), e && e.query && (this.query = e.query);
    },
    is_login: !1,
    login_complete: !1,
    windowWidth:wx.getSystemInfoSync().windowWidth,
    windowHeight:wx.getSystemInfoSync().windowHeight,
    img_src:'https://wxmall.sgwxmini.com/web/uploads/image/store_1/del/',
    customerId:wx.getStorageSync('customerId') || '',
    querystring(url) {
        return '/pages/web/web?url='+encodeURIComponent(url)
    },
    globalData: {
        user_id: null,
        //变美模块 
        tempPhoto:"",
        // 描点缩放比
        pie:"",
        //变美魔镜 前后图片
        imgArr:[],
        // 美学三维 参数
        mxswArg:{},
        // 脸部信息
        dotInfo:[],
        // 当前解决方案
        currenSolution:""
    },
};

for (var i in modules) args[modules[i].name] = require("" + modules[i].file);

var _web_root = args.api.index.substr(0, args.api.index.indexOf("/index.php"));

args.webRoot = _web_root, args.getauth = function(t) {
    var o = this;
    o.core.showModal({
        title: "是否打开设置页面重新授权",
        content: t.content,
        confirmText: "去设置",
        success: function(e) {
            e.confirm ? o.hj.openSetting({
                success: function(e) {
                    t.success && t.success(e);
                },
                fail: function(e) {
                    t.fail && t.fail(e);
                },
                complete: function(e) {
                    t.complete && t.complete(e);
                }
            }) : t.cancel && o.getauth(t);
        }
    });
}

args.getStoreData = function() {
    let t = this, api = this.api, core = this.core;

    t.request({
        url: api.default.store,
        loading:true,
        success: function(e) {
            0 == e.code && (core.setStorageSync(t.const.STORE, e.data.store), core.setStorageSync(t.const.STORE_NAME, e.data.store.name),
                core.setStorageSync(t.const.SHOW_CUSTOMER_SERVICE, e.data.store.show_customer_service), core.setStorageSync(t.const.CONTACT_TEL, e.data.store.contact_tel),
                core.setStorageSync(t.const.SHARE_SETTING, e.data.share_setting), t.permission_list = e.data.permission_list,
                core.setStorageSync(t.const.WXAPP_IMG, e.data.wxapp_img), core.setStorageSync(t.const.WX_BAR_TITLE, e.data.wx_bar_title), 
                core.setStorageSync(t.const.STORE_CONFIG, e.data),
                setTimeout(function() {
                    t.config = e.data, t.configReadyCall && t.configReadyCall(e.data);
                    t.page.getAppUserInfo()
                }, 1e3));
        },
        complete: function() {}
    });
}

var app = App(args);